package com.tonny.tweet.service.impl;

import com.tonny.tweet.dao.UserDao;
import com.tonny.tweet.model.User;
import com.tonny.tweet.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    
    @Autowired
    private UserDao userDao;
    
    @Override
    public User login(String username, String password) {
        return userDao.queryByUserNameAndPassword(username, password);
    }
    
    @Override
    public User register(User user) {
        userDao.insert(user);
        return user;
    }
    
    @Override
    public boolean isUsernameUsable(String username) {
        return userDao.queryByUserName(username) == null;
    }
}
